home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Mac OS Development Toolkit / Automation Essentials 2.3.0 / Host Automation Folder / Clouseau libs / 68040CacheSwitchCP.lib < prev    next >
Encoding:
Text File  |  1998-03-19  |  4.8 KB  |  145 lines  |  [TEXT/MPS ]

  1. #########################################################################
  2. #########################################################################
  3. ##                     Copyright © Apple Computer, Inc. 1992-1997
  4. ##                                All rights reserved
  5. #########################################################################
  6. #########################################################################
  7. #    
  8. #    Library:        68040CacheSwitch.lib
  9. #    
  10. #    Version:        2.1.4
  11. #    
  12. #    Description:    Tasks that handle the Cache Switch control panel. 
  13. #                    It turns on and off the 68040 Caches for compatibility.
  14. #                    Not really needed in 1995, because broken apps have 
  15. #                    been fixed or discontinued.
  16. #    
  17. #    Contains:
  18. #        CacheSwitchCP()
  19. #    
  20. #    History:
  21. #        Date:        By:        Changes:
  22. #         11/03/92    NMS        Created
  23. #         06/05/93    SBR        changes to CacheSwitchCP()
  24. #        09/03/94    SBR        changes to CacheSwitchCP()
  25. #        09/23/94    SBR        changes to CacheSwitchCP()
  26. #        09/04/95    SBR        Added this header for Radar 1273927
  27. #                            Formatted according to standards.
  28. #        09/27/96    SBR/MSO    Updated copyright header
  29. #                            Use SPEC exception handling method (ExceptionHandling.lib)
  30. #        01/21/97    SBR        Deleted older exception code and comments.
  31. #    
  32. #########################################################################
  33. #########################################################################
  34.  
  35. Libraries
  36.     "Clouseau.lib", 
  37.     "ExceptionHandling.lib", 
  38.     "Report.lib", 
  39.     "TargetControl.lib";
  40.  
  41. #########################################################################
  42. #    task                CacheSwitchCP(speed, v_level)
  43. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  44. # Author:        NS
  45. # Description:    Determines if the CPU has a 68040, if not returns undefined.
  46. #                If it has a 68040 it tries to open the Cache Switch control 
  47. #                Panel. If it can't it returns true, assuming the caches are on.
  48. #                If it can open the CP, it sets the cache according to the speed 
  49. #                parameter. True ensures it is on and false turns it off. If 
  50. #                the Control Panel is already set to the correct position it 
  51. #                does nothing.
  52. # Parameters:    speed :=    true = Set fast
  53. #                            false = Set slow
  54. #                            undefined (default) = Get current state
  55. # Returns:        Set: Success (true) or failure (false) or not 68040 (undefined)
  56. #                 Get: Fast (true) or Slow (false) or not 68040 (undefined)
  57. # Example:        CacheSwitchCP(true);            
  58. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  59. # History       Who        What
  60. #     11/03/92    NMS        Created
  61. #     06/05/93    SBR        Uses get_target_info() instead of explicit globals
  62. #     09/03/94    SBR        Added error handling for target access
  63. #     09/23/94    SBR        Now closes Control panels window in open_control_panel()
  64. #########################################################################
  65. task    CacheSwitchCP(speed := undefined, v_level := 5)
  66. begin
  67.     fastClick := {110,49};        #top FAST button
  68.     slowClick := {110,68};        #bottom SLOW button
  69.     
  70.     processorType := get_target_info('processor#');
  71.     if isUndefined(processorType)
  72.         processorType := _Gestalt('proc')[2][2];
  73.     if not (processorType = 5) 
  74.     begin 
  75.         RStatus("CacheSwitchCP: Target's CPU is not a 68040", v_level);
  76.         return undefined;
  77.     end;
  78.     
  79.     ohFortyCaches := get_target_info('68040CacheCP#');    
  80.     if isUndefined(speed) and not isUndefined(ohFortyCaches)
  81.         return ohFortyCaches;
  82.  
  83.     triedOnce := false;
  84.     while true 
  85.     begin     
  86.         await_presence([menuItem t:'Control Panels' m:1],,,,6);
  87.         if not open_control_panel("Cache Switch", true)
  88.             return true;    # assume caches are on if there is no Cache Switch CP
  89.             
  90.         try 
  91.             match [radioButton s:$b w:1];    # get the list of button settings
  92.         catch theError
  93.             ExceptionDispatcher(theError,,{"CacheSwitchCP", {speed}});
  94.         
  95.         if b[2] = { 1, 1 } 
  96.             ohFortyCaches := 'on';
  97.         else
  98.             ohFortyCaches := 'off';
  99.             
  100.         if isUndefined(speed) 
  101.         begin
  102.             key_eq('w');                # 09/23/94 SBR: was 'ww'
  103.             RStatus("CacheSwitchCP: 68040 caches are On", v_level);
  104.             return ohFortyCaches = 'on';
  105.         end;
  106.         if speed 
  107.         begin                    # user wants FAST 
  108.             if b[2] = { 1, 1 } 
  109.             begin
  110.                 key_eq('ww');
  111.                 return RStatus("CacheSwitchCP: 68040 caches are On", v_level);
  112.             end;
  113.             else 
  114.             begin 
  115.                 if triedOnce 
  116.                     return RError("CacheSwitchCP: Failed to turn on 68040 caches.", v_level);
  117.                 move_mouse({ fastClick, 'click' });
  118.                 triedOnce := true;
  119.                 RStatus("CacheSwitchCP: 68040 caches have been turned on. Restarting…", v_level);
  120.                 restart_target();
  121.             end;
  122.         end;
  123.         else
  124.         begin                    # user wants SLOW 
  125.             if b[1] = { 1, 1 } 
  126.             begin
  127.                 key_eq('ww');
  128.                 RStatus("CacheSwitchCP: 68040 caches are Off", v_level);
  129.                 return false;
  130.             end;
  131.             else 
  132.             begin    
  133.                 if triedOnce 
  134.                     return RError("CacheSwitchCP: Failed to turn off 68040 caches.", v_level);
  135.                 move_mouse({ slowClick, 'click' });
  136.                 triedOnce := true;
  137.                 RStatus("CacheSwitchCP: 68040 caches have been turned off. Restarting…", v_level);
  138.                 restart_target();
  139.             end;
  140.         end; 
  141.     end;
  142. end;  
  143.  
  144.  
  145.